<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>新增模块</title>
	 <link rel="stylesheet" href="../../js/layui/css/layui.css">
    <style type="text/css">
        form{
            margin: 20px;
        }
        ul li {
            list-style: none;
        }
    </style>
</head>
<body>
		<form class="layui-form" action="">
<div>
    <ul>
        <li>模块名称:<input type="text" id="name" name="name"/></li>
        <li>模块URL:<input type="text" id="url" name="url"/></li>
        <li>模块描述:<input type="text" id="des" name="des"/></li>
        <li>是否推送: <input type="checkbox" checked="" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="推送|不推送">
            <input type="hidden" id="flag" value="1" /></li>
        <li><input type="button" value="提交" id="btn"/></li>
    </ul>
</div>
</form>
</body>

<script src="../../js/jquery.min.js"></script>
<script src="../../js/common.js"></script>
<script src="../../js/jquery.cookie.js"></script>
<script src="../../js/layer/layer.js"></script>
<script type="text/javascript" src="../../js/layui/layui.js"></script>
<script>

    layui.use(['form'], function(){
        var form = layui.form;
        //监听指定开关
        form.on('switch(switchTest)', function(data){
            if(this.checked){
                $("#flag").val(1);
            }else{
                $("#flag").val(0);
            }
        });
    });

    $(function () {
        $("#btn").click(function () {
            submit();
        });
    });
    function submit() {

        var clazz = {
            name:$("#name").val(),
            url:$("#url").val(),
            des:$("#des").val(),
            flag:$("#flag").val()

        }
        $.ajax({
            type: "post",
            dataType:"json",
            contentType: "application/json",
            url: baseUrl+"module/new.json",
            data: JSON.stringify(clazz),
            success: function (data) {
                if (data.code == "200") {
                    window.location.href = "list.html";
                } else {
                    layer.msg("修改失败!",{icon:5});
                }
            }
        });
    }

</script>
</html>